package com.fr.report.script.function;

import com.fr.report.script.Function;
import com.fr.report.script.Function.Type;
import com.fr.report.script.NormalFunction;

public class RAND extends NormalFunction
{
  public Object run(Object[] paramArrayOfObject)
  {
    return new Double(Math.random());
  }

  public String getCN()
  {
    return "RAND(): 返回均匀分布的随机数。每计算一次工作表，函数都会返回一个新的随机数值。\n备注:\n    要生成一个位于a和b之间的随机数，可以使用以下的公式: C=RAND()*(b-a)+a。\n    如果要使一个随机产生的数值不随单元格的重计算而改变，可以在编辑框中输入=RAND()并保持编辑状态，然后按F9，将公式永久性地改为随机数。\n示例:\n假如需要生成一个大于等于0，小于60的随机数，使用公式: =RAND()*60。\n假如需要生成一个大于等于0，小于19的随机数，使用公式: =RAND()*19。\n假如需要生成一个大于等于0，小于50的随机数，使用公式: =RAND()*50。";
  }

  public Function.Type getType()
  {
    return Function.MATH;
  }

  public String getEN()
  {
    return "RAND(): Returns an evenly distributed random number greater than or equal to 0 and less than 1. A new random number is returned every time the worksheet is calculated.\n\nRemarks:\n1. To generate a random real number between a and b, use: RAND()*(b-a)+a\n2. If you want to use RAND to generate a random number but don't want the numbers to change every time the cell is calculated, you can enter =RAND() in the formula bar, and then press F9 to change the formula to a random number. \n\nExample:\n   If you want to get a rand number equal or greater than 0, and smaller than 60, use: RAND()*60。";
  }
}